﻿//Write a program that downloads a file from Internet (e.g. http://www.devbg.org/img/Logo-BASD.jpg)
//and stores it the current directory. Find in Google how to download files in C#.
//Be sure to catch all exceptions and to free any used resources in the finally block.


using System;
using System.Net;

public class DownloadsFile
{
    public static void Main(string[] args)
    {
        WebClient webClient = new WebClient();
        string webAddres = "http://www.devbg.org/img/";
        string fileName = "Logo-BASD.jpg";
        Console.WriteLine("Downloading File \"{0}\" from \"{1}\"\n", fileName, webAddres + fileName);

        try
        {
            webClient.DownloadFile(webAddres + fileName, fileName);
        }
        catch (ArgumentNullException ae)
        {
            Console.WriteLine("{0}", ae.Message);
        }
        catch (WebException we)
        {
            Console.WriteLine("{0}", we.Message);
        }
    }
}